
{% extends "admin/common/layout.html" %}
{% block active %}menu{% endblock %}
{% block body %}
<h2>菜单管理</h2>
{% include "admin/common/flash.html" %}
{% include "admin/menu/nav.html" %}
<style type="text/css">
form.search {margin-bottom: 15px;}
form .group_offset {margin-right: 20px; margin-top: 5px}
form .label_offset {margin-right: 10px}
</style>
<form class="form-inline search" role="form" >
    <div class="form-group group_offset" >
        <label class="control-label label_offset">名称</label>
        <input type="text" class="form-control" id="name" name="name" placeholder="检索名称" value="{{ req.name or '' }}" >
    </div>
    <div class="form-group group_offset" >
        <label class="control-label label_offset">菜单URL</label>
        <input type="text" class="form-control" id="url" name="url" placeholder="检索菜单URL" value="{{ req.url or '' }}" >
    </div>
    <div class="form-group group_offset" role="toolbar">
        <div class="btn-group" role="group">
            <button type="submit" class="btn btn-default">检索</button>
        </div>
    </div>
</form>
<table class="table table-striped">
<thead>
    <tr>
        <th>ID</th>
        <th></th>
<th>名称</th><th>菜单URL</th>
    </tr>
</thead>
<tbody>
    {% for item in list %}
    <tr>
        <td>{{ item.id }}</td>
        <td>
            <a href="{{ url_for('admin.menu_edit', id=item.id) }}">
                <span class="fa fa-pencil glyphicon glyphicon-pencil"></span>
            </a>
            <form class="icon" method="POST" action="{{ url_for('admin.menu_del') }}" id='form_{{ item.id }}' style='display: inline;'>
                <input id="id" name="id" type="hidden" value="{{ item.id }}">
                <a href="#" id='btn_del' data-id='{{ item.id }}'>
                    <span class="fa fa-trash glyphicon glyphicon-trash"></span>
                </a>
            </form>
        </td>
<td>{{ item.name }}</td><td>{{ item.url }}</td>
    </tr>
    {% endfor %}
</tbody>
</table>
{% include "admin/common/page.html" %}
<script>
$(function(){
    $('#btn_del').click(function() {
        if (confirm('是否确定要删除该记录？')) {
            var id = $(this).data('id')
            $('#form_' + id).submit()
        }
    })
})
</script>
{% endblock %}
